package com.zxy.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 自定义全局网关Filter
 *
 * @author: Zxy
 * @Date: 2021-06-11
 **/
public class CustomerGlobalFilter implements GlobalFilter, Ordered {

    // exchange：交换信息 封装了request和response  chain：调用链
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        // 放行filter继续执行
        return chain.filter(exchange);
    }

    // order排序 默认按照自然数字进行排序 比如0会在1之前先执行
    @Override
    public int getOrder() {
        return 0;
    }
}
